using System;
using System.Collections.Generic;
using RaisingStudio.SmallBasicCompiler.Completion;

namespace RaisingStudio.SmallBasicCompiler.Statements
{
	public abstract class Statement
	{
		public TokenInfo StartToken
		{
			get;
			set;
		}
		public TokenInfo EndingComment
		{
			get;
			set;
		}
		public virtual void AddSymbols(SymbolTable symbolTable)
		{
		}
		public virtual void PrepareForEmit(CodeGenScope scope)
		{
		}
		public virtual void EmitIL(CodeGenScope scope)
		{
		}
		public virtual void PopulateCompletionItems(CompletionBag completionBag, int line, int column, bool globalScope)
		{
			CompletionHelper.FillAllGlobalItems(completionBag, globalScope);
		}
		public virtual int GetIndentationLevel(int line)
		{
			return 0;
		}
		public static Statement GetStatementContaining(List<Statement> statements, int line)
		{
			for (int i = statements.Count - 1; i >= 0; i--)
			{
				Statement statement = statements[i];
				if (line >= statement.StartToken.Line)
				{
					return statement;
				}
			}
			return null;
		}
	}
}
